<?php
/* @var $this ShopMenuController */
/* @var $model ShopMenu */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'shop-menu-_shopmenu-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // See class documentation of CActiveForm for details on this,
        // you need to use the performAjaxValidation()-method described there.
        'enableAjaxValidation' => false,
    ));
    ?>

    <?php echo $form->errorSummary($model); ?>

    <div class="form_left">
        <?php echo $form->labelEx($model, 'shopid'); ?>
    </div>
    <div class="form_right">
        <?php
        $session = new CHttpSession;
        $session->open();
        $userID = $session['user_salesmart'][3];

        $listshop = Shop::model()->findAll('flag in(1,4) and uid=' . $userID);

        $list = CHtml::listData($listshop, 'id', 'shopName');

        echo $form->dropDownList($model, 'shopid', $list, array('prompt' => '----- Chọn gian hang -----',
            'ajax' => array(
                'type' => 'POST', //request type
                'url' => CController::createUrl('manager/dynamicmenushop'), //url to call.
                'update' => '#parentID', //selector to update
                'data' => array('id' => 'js:this.value'),
        )));
        // echo $form->textField($model,'programid'); array( 'onchange' => 'document.location.href = "' . Yii::app()->request->baseUrl . '/them-city/" + this.value')
        ?>
        <?php echo $form->error($model, 'shopid'); ?>

    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'title'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'title', array('size' => 60, 'maxlength' => 50, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'title'); ?>
    </div>
    <div class="clear"></div>



    <div class="form_left">
        <?php echo $form->labelEx($model, 'parentID'); ?>
    </div>
    <div class="form_right">
        <?php
        if (isset($model->shopid)) {
            $session = new CHttpSession;
            $session->open();
            //$session['user_salesmart'][3];

            $listsmenu = ShopMenu::model()->findAll('parentID=0 and flag=1 and uid=' . $model->uid . ' and shopid=' . $model->shopid);
            $listmenu = CHtml::listData($listsmenu, 'id', 'title');
            echo $form->dropDownList($model, 'parentID', $listmenu, array('prompt' => '----- Chọn menu cha -----', 'id' => 'parentID'));
        } else {
            echo $form->dropDownList($model, 'parentID', array(), array('prompt' => '----- Chọn menu cha -----', 'id' => 'parentID'));
        }
        ?>



        <?php echo $form->error($model, 'parentID'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'url'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'url', array('size' => 60, 'maxlength' => 200, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'url'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'flag'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->dropDownList($model, 'flag', array('1' => 'Hiễn thị', '0' => 'Ẩn')); ?>
        <?php echo $form->error($model, 'flag'); ?>
    </div>

    <div class="clear">.</div>
    <div class="form_left">.</div>
    <div class="form_right">
        <?php echo CHtml::submitButton('Cập nhật'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->